package webhook

import (
	"cron-go/internal/pkg/utils/httpclient"
)

const timeOut = 4

type Hook struct {
	Url   string
	Token string
	Body  string
}

func New(url string, token string) *Hook {
	return &Hook{
		Url:   url,
		Token: token,
	}
}

func (s *Hook) PostJson(body string) httpclient.ResponseWrapper {
	header := make(map[string]string, 0)
	header["Content-type"] = "application/json"
	header["Authorization"] = s.Token
	return httpclient.RequestData(httpclient.POST, s.Url, body, header, timeOut)
}
